package com.sky.config;

import com.sky.properties.AliOssProperties;
import com.sky.utils.AliOssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//配置类 读取配置属性
@Slf4j
@Configuration
public class aliossConfig {

    @Bean//项目启动时创建对象交给bean对象
    @ConditionalOnMissingBean
    //AliOssProperties是为了不在括号里写过多的属性，这是利用了封装
    public AliOssUtil alioss(AliOssProperties aliOssProperties) {
      log.info("喜欢你吗喜欢我呀");
        return new AliOssUtil(aliOssProperties.getEndpoint(),
                aliOssProperties.getAccessKeyId(),
                aliOssProperties.getAccessKeySecret(),
                aliOssProperties.getBucketName()
        );
    }
}
